<template>
  <el-dialog :title='config.title' :visible.sync='config.active' :width='config.width' :before-close="beforeClose">
    <component :is="component"></component>
  </el-dialog>
</template>

<script>


export default {
  name: 'Dialog',
  props: {
    config:Object
  },
  watch: {
    config(n) {
      this.component = () => import('@/'+n.component)
    }
  },

  data(){
    return {
      component: {}
    }
  },
  components:{

  },
  methods: {
    beforeClose(done) {
      if(this.config.beforeClose) {
        this.config.beforeClose()
      }
      done()
    }
  }

}

</script>

